#ifndef DBTIME_H
#define DBTIME_H

#include "main_inc.h"
#include "time.h"
#include "clog.h"

#define DAY 86400
#define HOUR    3600
#define MINUTE  60


struct db_time
{
	time_t time;
	u16 milisecond;
};

struct db_specTime
{
    i32 year;
    i32 month;
    i32 day;
    i32 hour;
    i32 minute;
    i32 second;
    i32 dst;
    i32 milisecond;
};

class DBTime
{
	public:
		DBTime();
		virtual ~DBTime();

		// ----------------------

        db_time dt;

		db_time Serialize();
		i32 Deserialize ( db_time time );
		i32 FromSystemTime ( time_t time );
		time_t ToSystemTime ();

		void Fill ( u8 d, u8 m, u16 y, u8 h, u8 mi, u8 s, u16 ms, i32 dst = -1 );
		void FillTime ( u8 h, u8 mi, u8 s, u16 ms, i32 dst = -1 );
		void Actual();

        db_specTime translate();


		string TimeDateToString();
		string TimeToString();
		string DateToString();

		static string TimeDateToString(time_t &tm);
		static string TimeToString(time_t &tm);
		static string DateToString(time_t &tm);

//
//        time_t calculateTimeChangeDateSummer(u32 year);
//        time_t calculateTimeChangeDateWinter(u32 year);
//
//        static i32 summer_offset;
//        static i32 winter_offset;
//
};

#define DS_TIME(arg)   (DBTime::TimeToString( arg ).c_str())
#define DS_DATE(arg)   (DBTime::DateToString( arg ).c_str())
#define DS_TD(arg)   (DBTime::TimeDateToString( arg ).c_str())



#endif // DBTIME_H
